import {ref} from 'vue'
import {goDialog, MessageError, MessageSuccess} from '@/utils'
import {DialogEnum} from '@/enums/pluginEnum'
import {ChartList, Chartype} from '../../..'
// @ts-ignore
import UserPageApi from "@/api/flow/UserPageApi.js";
import {Project} from "@/api/ProjectsApi";
// 数据初始化
export const useDataListInit = () => {
    // 删除
    const deleteHandle = (cardData: Chartype, index: number, callback: Function) => {
        goDialog({
            type: DialogEnum.DELETE,
            promise: true,
            onPositiveCallback: () => {
            },
            promiseResCallback: (e: any) => {
                Project.Delete(cardData.Id).then(res => {
                    if (res) {
                        MessageSuccess('删除成功')
                    } else {
                        MessageError('删除失败')
                    }
                    callback()
                });
            }
        })
    }

    return {
        deleteHandle
    }
}
